export class Permission {
  /**
   *
   */
  list: string[];
  separator: string;
  level: number;

  constructor(list: string[], level = 3, separator = ":") {
    this.list = list;
    this.level = level;
    this.separator = separator;
  }

  isValid(str: string) {
    const p = new Array(this.level).fill("\\w+?").join(":");
    // ^\w+?:\w+?:\w+?$
    const r = new RegExp(`^${p}$`);
    return r.test(str);
  }
}
